package cn.com.frame.app.controller;

import cn.com.frame.app.pojo.po.FtMenu;
import cn.com.frame.app.service.FtMenuService;
import cn.com.frame.commom.web.BaseController;
import cn.com.frame.commom.web.RespData;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/menu")
public class FtMenuController extends BaseController {

    @Autowired
    private FtMenuService ftMenuService;

    @GetMapping("/getPageData")
    public RespData getPageData(@RequestParam("page")Integer page, @RequestParam("size")Integer size ,
                                @RequestParam(value="menuName",required=false)String menuName){

        return reSuccess(ftMenuService.getPageData(page,size,menuName));
    }

    @GetMapping("/selectByPrimaryKey")
    public RespData selectByPrimaryKey(@RequestParam("id")long id){
        FtMenu ftMenu = ftMenuService.selectByPrimaryKey(id);
        return reSuccess(ftMenu);
    }

    @PostMapping("/updateByPrimaryKey")
    public String updateByPrimaryKey(@RequestBody FtMenu param){
        return ftMenuService.updateByPrimaryKey(param)+"";
    }

    @PostMapping("/insert")
    public int insert(@RequestBody FtMenu param){
        int r = ftMenuService.insert(param);
        System.out.println(JSON.toJSONString(param));
        return  r;
    }

    @PostMapping("/delete")
    public String delete(@RequestBody long id){
        return ftMenuService.delete(id)+"";
    }


}
